package com.sun.mapper;

import com.sun.config.SpringConfig;
import com.sun.pojo.entity.PurchaseOrders;
import com.sun.pojo.entity.PurchaseSettlement;
import com.sun.pojo.vo.R;
import com.sun.service.PurchaseOrdersService;
import com.sun.service.PurchaseSettlementService;
import com.sun.utils.DateUtil;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.context.web.WebAppConfiguration;

/**
 * @author SunRui
 * @description TODO
 * @date 2024/10/28 10:22
 */
@RunWith(SpringRunner.class)
@ContextConfiguration(classes = SpringConfig.class)
@WebAppConfiguration
public class purchaseOrdersServiceById {

    @Autowired
    PurchaseOrdersService purchaseOrdersService;
    @Autowired
    PurchaseSettlementService purchaseSettlementService;
    @Test
    public void test(){
        String orderId = "1729824072072";
        String updatedBy = "admin";
        // 把订单中的数据拿出并且加入到结算表
        PurchaseSettlement purchaseSettlement = new PurchaseSettlement();
        // 存入ID
        purchaseSettlement.setPoId(orderId);
        // 通过id查询表单数据获取总价格
        PurchaseOrders purchaseOrders = purchaseOrdersService.queryById(orderId);
        System.out.println(purchaseOrders.toString());
//        purchaseSettlement.setTotalAmount(purchaseOrders.getTotalAmount());
//        purchaseSettlement.setSettlementStatus("0");
//        purchaseSettlement.setCreatedBy(updatedBy);
//        if (purchaseSettlementService.insert(purchaseSettlement)>0) {
//            // 更新订单状态
//            System.out.println("1");
//        }
    }

    @Test
    public void totalAmount(){
        String updatedAt = "";
        R r = purchaseOrdersService.totalAmount(updatedAt);
        System.out.println(r);
    }

    @Test
    public void test1(){
        DateUtil dateUtil = new DateUtil();
        System.out.println(dateUtil.getWeekDates()[0]);
    }
}
